/**
 * Created by Administrator on 2015/12/29.
 */
angular.module('maincontent.controller',[])
  .controller('mainContentCtrl',['$scope','$timeout' ,'$localstorage','$ionicPopup','mainContentService','$state','loginService',function($scope,$timeout,$localstorage,$ionicPopup,mainContentService,$state,loginService){
       
    $scope.NavJsonData=[];
    $scope.params=mainContentService.getParams();
    $scope.visible=true; //初始
    $scope.params.memberType=1;

    $scope.doRefresh = function () {
        $scope.params.Type_ID = 'APP65837';//获取首页配置
        $scope.params.Depart_Code = $localstorage.get("Depart_Code");
        $scope.params.User_ID = $localstorage.get("User_ID");
        $scope.params.Phone = $localstorage.get("Phone");

        mainContentService.get_twoLayerNavInfo($scope.params).then(function (data) {
            $scope.NavJsonData = data;
        }, function (error) {
            var alertPopup = $ionicPopup.alert({
                title: '获取首页失败！',
                template: "异常错误",
                okText: '确定', // String (默认: 'OK')。OK按钮的文字。
                okType: 'item-customer-bg-darkred', // String (默认: 'button-positive')。OK按钮的类型。
            });
        });
    };
    $scope.$on('$ionicView.enter', function(event, data) {
          console.log("主页进来了");
          if($scope.NavJsonData.length<=0){
            $scope.doRefresh();
          }
    });
    $scope.goYWKH = function(){
      $state.go("ywkh");
      $localstorage.set("commPreOrderId","SingleOpen");
    }
    $scope.goKDKH = function(){
      $state.go("kdkh");
      $localstorage.set("BandCommPreOrderId","SingleOpen");
    }
    $scope.doSomething = function(){
      alert('查询任务！');
    }

  }]);
